package com.learn.servloader;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ServLoaderTest implements CommandLineRunner {

    /**
     * 方式二：使用服务定位模式，耦合性较弱；只需要增加对应的枚举值和对应的组件类即可，不需要修改代码;
     * see enum： {@link ContentTypeV2} and {@link TypeConstants}
     * <p>
     * 方式一见{@link com.learn.servloader.switches.SwitchTest}
     */
    private ParseClientV2 parseClientV2;

    @Autowired
    public ServLoaderTest(ParseClientV2 parseClientV2) {
        this.parseClientV2 = parseClientV2;
    }

    @Override
    public void run(String... args) throws Exception {
        List list = parseClientV2.getAll(ContentTypeV2.XML);

        System.out.println("list = " + list.size());
    }

}
